<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="author" content="zxh">
    <title>图片翻转</title>
    <style>
        * {
            box-sizing: border-box;
        }
        
        ul,
        li,
        h2 {
            margin: 0;
            padding: 0;
            list-style: none;
        }
        
        main {
            width: 312px;
            margin: 0 auto;
            border: 1px solid #ccc;
        }
        
        main h2 {
            height: 40px;
            line-height: 40px;
            font-size: 16px;
            color: #333;
            text-align: center;
            border-bottom: 1px solid #000;
        }
        
        main ul {
            padding: 0 15px;
            overflow: hidden;
        }
        
        main ul li {
            float: left;
            width: 120px;
            height: 75px;
            margin: 10px;
            position: relative;
        }
        
        main li img {
            width: 120px;
            height: 75px;
            border: 1px solid #ccc;
            position: absolute;
            top: 0;
            left: 0;
            z-index: 2;
        }
        
        main li span {
            display: inline-block;
            width: 120px;
            height: 0px;
            line-height: 75px;
            color: #fff;
            text-align: center;
            border: 1px solid #ccc;
            background-color: orange;
            display: none;
            position: absolute;
            top: 0;
            left: 0;
            z-index: 1;
        }
    </style>
</head>

<body>
    <main>
        <h2>热门品牌推荐</h2>
        <ul>
            <li>
                <a href="#"><img src="images/11.jpg"><span>韩束</span></a>
            </li>
            <li>
                <a href="#"><img src="images/22.jpg"><span>韩束</span></a>
            </li>
            <li>
                <a href="#"><img src="images/33.jpg"><span>韩束</span></a>
            </li>
            <li>
                <a href="#"><img src="images/44.jpg"><span>韩束</span></a>
            </li>
            <li>
                <a href="#"><img src="images/55.jpg"><span>韩束</span></a>
            </li>
            <li>
                <a href="#"><img src="images/66.jpg"><span>韩束</span></a>
            </li>
            <li>
                <a href="#"><img src="images/77.jpg"><span>韩束</span></a>
            </li>
            <li>
                <a href="#"><img src="images/88.jpg"><span>韩束</span></a>
            </li>
        </ul>
    </main>
</body>

</html>
<script src="js/jquery.js"></script>
<script>
    var aLi = $('main li')
    var aImg = $('main li img')
    var aSpan = $('main li span')
    aLi.each(function (index) {
        $(this).mouseover(function () {
            aImg.eq(index).stop()
            aSpan.eq(index).stop()
            // 鼠标进来图片高度为0 当图片高度变为0之后， 紧接着让文字显示
            aImg.eq(index).css('z-index', 1).animate({
                height: 0,
                top: 37,
            }, 80, function () {
                // 图片隐藏
                $(this).hide()
                // 动画结束后让文字显示
                aSpan.eq(index).css('z-index', 2).animate({
                    height: 75,
                    top: 0,
                }, 80)
            })
        })
        $(this).mouseout(function () {
            aImg.eq(index).stop()
            aSpan.eq(index).stop()
            // 鼠标出去 文字高度改为0 紧接着显示图片
            aSpan.eq(index).css('z-index', 1).animate({
                height: 0,
                top: 37
            }, 80, function () {
                  // 图片隐藏
                $(this).hide()
                // 显示图片
                aImg.eq(index).show().css('z-index', 2).animate({
                    height: 75,
                    top: 0
                }, 80)
            })

        })
    })

</script>